package cn.iocoder.yudao.module.promotion.gift.mq;

import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.api.promotion.gift.message.OnlineProductGiftTakeMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 引流赠品 事件生产者
 *
 * @author 山野羡民
 */
@Slf4j
@Component
public class GiftProducer {

    /**
     * 发送 {@link OnlineProductGiftTakeMessage} 消息
     *
     * @param shopId 店铺编号
     * @param tradeNo 交易单号
     * @param settlementMoney 结算金额
     */
    public void sendOnlineProductGiftTakeMessage(Long shopId, String tradeNo, Integer settlementMoney) {
        log.info("[sendOnlineProductGiftTakeMessage][shopId({}) tradeNo({}) settlementMoney({})]", shopId, tradeNo, settlementMoney);
        SpringUtil.getApplicationContext().publishEvent(new OnlineProductGiftTakeMessage(shopId, tradeNo, settlementMoney));
    }

}
